Command say and use to record multiples voices in one command

Hello,


I would like to know if it possible to use the command say with multiple voices together and to record it to a file.


For exemple, i would to record both "Good morning" from voice "Bruce" with also "Bonjour" from voice "Thomas" to a same file bonjour.aiff


I would write the command this way but it doesn't work :


say -v Bruce "Good morning" -v Thomas "Bonjour" -o bonjour.aiff


Have you got any idea , after all it may be not possible in the native application.


Best regards.


Olivier

MacBook Pro (Retina, 13-inch, Mid 2014), iOS 9.3.2

Posted on May 22, 2016 9:33 AM

Reply
10 replies

May 22, 2016 11:25 AM in response to la_lune_claire

You can't use say for that. Depending on how serious you are, you can create multiple speech synthesizers or output files, but you would need to synchronize them - the various voices do not speak with the same timings. You might be able to use something like a multi-track audio application to synchronize and save the output, otherwise you would need to use another utility (or write your own) to save the combined audio.

May 22, 2016 11:25 AM in response to red_menace

Ok thanks for your answer. I found it strange you say it is not possible despite all the possibilities given here :https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/ SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html

.

If it is not possible as you said it, at the end i arrive at the same conclusion to do it on my own with utilities that can merge the obtained output files.


Best regards,


Olivier

May 22, 2016 12:09 PM in response to la_lune_claire

The existing APIs (and say) provide ways to customize and save the speech output to a file, but they deal with individual voices. Multiple voices will result in multiple files, so you can run multiple voices and capture the combined output, or you can combine multiple voice files. Since you will need to synchronize the voices anyway (note that the exact speaking rate and the way the words themselves are spoken differ between voices), you could use something like Audacity to combine and synchronize to a single file.

May 24, 2016 1:48 AM in response to la_lune_claire

Hi Olivier. If you don’t mind installing additional components, one option is to use the command line sound processing utility SoX to mix individual audio files. If not installed, install the Homebrew package manager from Terminal:


/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”


Then install SoX:


brew install sox


The following series of commands will create two /tmp audio files (automatically deleted by the system after a preconfigured period of time), mix them together, and place the mixed audio file on the Desktop. Copy and paste the following as a block into Terminal:


say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

say -v Bruce "Good morning" -o /tmp/gm.aiff &&

sox -m /tmp/bj.aiff /tmp/gm.aiff ~/Desktop/bonjour.aiff


For best results use enhanced-quality voices. Because overlapping speech can create an aural muddle with poor distinction between the speech parts, you can add silence with the silence command [[slnc]] in milliseconds to adjust the amount of overlap. For instance:


say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

say -v Bruce "[[slnc 300]] Good morning" -o /tmp/gm.aiff &&

sox -m /tmp/bj.aiff /tmp/gm.aiff ~/Desktop/bonjour.aiff


If you want to play the speech synthesizers simultaneously and record to file from the command line without creating individual temp files, first install GNU parallel with Homebrew from Terminal:


brew install parallel


Use the following command and follow the directions to silence the citation notice:


parallel --bibtex


Additionally, download and install either iShowU Audio Capture or Soundflower to be able to capture system sound. Once installed, open the Audio MIDI Setup app located in /Applications/Utilities/. Press the '+' button in the bottom left corner and select "Create Multi Output Device”.

User uploaded file

If using iShowU Audio Capture, select both "Built-in Output” and "iShowU Audio Capture” in the right side panel. If using Soundflower, select both "Built-in Output” and "Soundflower (2ch)”. In either case, if selected, deselect “Drift Correction” as a starting point. You can change the name from Multi-Output Device in the left side panel by clicking on it.

User uploaded file

With either iShowU Audio Capture or Soundflower, select the corresponding Multi-Output-Device in the left side panel, click the gear icon in the bottom left and select "use this device for sound output”.

User uploaded file

Still in the left side panel, select either "iShowU Audio Capture” or "Soundflower (2ch)”, click the gear icon in the bottom left and select “use this device for sound input”. In the right side panel, click the Input button and reduce the master volume (M) to a value of 0.96 or less to prevent clipping.

User uploaded file

Note the microphone and speaker icons for the currently selected input and output. You can also select input and output devices by navigating to  > System Preferences > Sound.


In Terminal, use the following piped commands which will place an audio file on the Desktop:

parallel ::: 'say -v Bruce "Good morning"' 'say -v Thomas "Bonjour"' | rec ~/Desktop/bonjour.aiff trim 0 00:02


Adjust the recording time, 2 seconds in the above example (00:02), as necessary.

User uploaded file

Tested with OS X Yosemite 10.10.5

May 24, 2016 10:07 AM in response to la_lune_claire

Hello


Here's another option to use ffmpeg. You may obtain pre-compiled binaries for OS X from the following source.


http://www.ffmpegmac.net/



Download the zip archive, expand it and copy ffmpeg, ffprobe and ffserver to, e.g., /usr/local/bin.


E.g.,



#!/bin/bash SITE='http://www.ffmpegmac.net/resources' FILE='SnowLeopard_Lion_Mountain_Lion_Mavericks_Yosemite_El-Captain_02.05.2016.zip' DIR=~/Desktop/ffmpeg_install_temp # cd to temp directory mkdir -p "$DIR" && cd "$DIR" || exit # download zip archive curl -O "${SITE}/${FILE}" || exit # expand archive unzip -u "$FILE" # chown and copy files to /usr/local/bin sudo chown root:wheel ffmpeg ffprobe ffserver sudo cp -pPR ffmpeg ffprobe ffserver /usr/local/bin




And here's a sample script to concatenate and/or mix audio files generated by say command using ffmpeg. I'd presume you're concatenating files rather than mixing them.



#!/bin/bash DIR=~/Desktop/test mkdir -p "$DIR" && cd "$DIR" || exit say 'Good morning' -v Bruce -o 'good_morning.aiff' say 'Bonjour' -v Ralph -o 'bonjour.aiff' FFMPEG=/usr/local/bin/ffmpeg # concatenate : using filter_complex, concat "$FFMPEG" \ -i good_morning.aiff \ -i bonjour.aiff \ -filter_complex '[0:a] [1:a] concat=n=2:v=0:a=1 [aout]' \ -map '[aout]' \ -y \ bonjour1.aiff # mix (mixdown to stereo) : using filter_complex amerge and -ac 2 option "$FFMPEG" \ -i good_morning.aiff \ -i bonjour.aiff \ -filter_complex '[0:a] [1:a] amerge=inputs=2 [aout]' \ -map '[aout]' \ -ac 2 \ -y \ bonjour2.aiff # mix (file 1's L/R to output's L, file 2's L/R to output's R) : using filter_complex amerge, pan "$FFMPEG" \ -i good_morning.aiff \ -i bonjour.aiff \ -filter_complex '[0:a] [1:a] amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3 [aout]' \ -map '[aout]' \ -y \ bonjour3.aiff




For complete documentation of ffmpeg, you may explore the following


https://ffmpeg.org/documentation.html



Scripts are tested under OS X 10.6.8.


Good luck,

H

May 24, 2016 1:06 PM in response to la_lune_claire

Hello Hiroto,

Hello Roote,


Thank you very much for this help abundant in details and rigorous.

I really appreciate.


These are solutions and are helpful but i prefer one, it is using ffmpeg.


First of all, i don't want to install brew like that, i prefer to keep my mac clean from it (may be i will use it in the future but not now).

And luckily you can use pre-compiled sox in here : https://sourceforge.net/projects/sox/files/sox/ , for mac.


So also you can use ffmpeg , and you nicely gave a bash script to do so that i will use.


I have not yet studied Sox so far, but i guess i will be able to concatenate files like m4a more easily with ffmpeg.

Work with aiff is good but if you have big files and running bash with these big files and concatenate it , it might become not so easy regarding the system.


I have not yet tried but i think i will work with m4a, for reasons of vigilance and space.


For your information, i'm just trying to read simultaneously the Coran in Arabic langage and french ; it is interesting and so also is "say" , full of possibilities.


Thank you again,


Olivier


Best regards

May 30, 2016 1:20 AM in response to la_lune_claire

If using SoX to concatenate and wanting a .m4a file, you can use afconvert:

say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

say -v Bruce "Good morning" -o /tmp/gm.aiff &&

sox /tmp/bj.aiff /tmp/gm.aiff /tmp/bjgm.aiff &&

afconvert -f m4af /tmp/bjgm.aiff ~/Desktop/bonjour.m4a


This will convert an 84 KB .aiff tmp file to a 12 KB .m4a file.


For afconvert help on the command line:


afconvert -h


To print a list of supported file formats:


afconvert -hf

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Command say and use to record multiples voices in one command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.